#pragma once

enum EDataType
{
	Data_Undef = 0, 
	Data_Bool,
	Data_S32,
	Data_U32,
	Data_F32,
	Data_Vector2,
	Data_Vector3,
	Data_Rot4,
	Data_Color4,
	Data_DString,
	Data_SString,
	Data_Enum,
	Data_Struct_Ins,
	Data_RefObj_Ptr,
	Data_Type_Count,
};

size_t RawTypeSize( EDataType type, bool isAry = false);

// types
typedef char				as_char_t, s8_t;
typedef Ogre::uchar			uchar_t, u8_t, byte_t;
typedef signed short		sword_t, s16_t;
typedef Ogre::ushort		ushort_t, u16_t, word_t;
typedef int					sbyte_t, int_t, s32_t;
typedef Ogre::uint			ulong_t, dword_t, uint_t, u32_t;

typedef Ogre::Real			f32_t, vec1_t;
typedef Ogre::Vector2		vec2_t;
typedef Ogre::Vector3		vec3_t;
typedef Ogre::Vector4		vec4_t;
typedef Ogre::Quaternion	quad4_t, rot4_t;
typedef Ogre::ColourValue	color_t, color4_t;

enum { MaxU8 = 0xff };
enum { MaxS8 = 0x7f };
enum { MaxS32 = 0x7fffffff };

#define null_index -1 
#define null_ptr NULL 




#ifndef JADE_THREAD
// no thread ver.
inline void coreAtomicInc( s32_t& val)
{
	++val;
}

inline void coreAtomicDec( s32_t& val)
{
	--val;
}

inline void coreAtomicInc( u32_t& val)
{
	++val;
}

inline void coreAtomicDec( u32_t& val)
{
	--val;
}
#endif

/*
show err dialog
*/
void coreErrDialog( const as_char_t* expr, const as_char_t* fileName, s32_t lineNum);

inline void coreMemzero( void* ptr, s32_t size)
{
	if( size)
	{
		memset( ptr, 0, size);
	}
}

inline void coreMemcpy( void* dst, const void* src, s32_t size)
{
	if( size)
	{
		memcpy( dst, src, size);
	}
}

inline void coreMemmove( void* dst, const void* src, s32_t size)
{
	memmove( dst, src,size);
}

void* coreRealloc(void* ptr, u32_t oldSize, u32_t newSize);
void* coreAlloc( u32_t size);
void coreFree( void* data);

char* coreStrcpy(char* dst, s32_t dstSize, const char* src);
char* coreStrncpy( char* dst, s32_t dstSize, const char* src, s32_t srcSize);



#if _DEBUG
#define JADE_CHECK 1
#endif

#if JADE_CHECK
	#define _check( chk)  {if(!(chk)) coreErrDialog( #chk, __FILE__, __LINE__ );}
#else
	#define _check( chk) {}
#endif


class DString;
class SString;
class Obj;
template <typename T> class RefPtr;

